package com.red.star.macalline.data.mappers;


import com.red.star.macalline.data.core.base.MyMapper;
import com.red.star.macalline.data.entity.Merchant;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.springframework.data.mongodb.repository.Query;

import java.util.List;

/**
 * @Author: Yenan
 * @Description:
 * @Date: Created in 14:30 2018/2/5
 */
public interface MerchantMapper extends MyMapper<Merchant> {
	List getAllCategoryByMallCode(String mallCode);

	List<Merchant> getMerchantsByCategoryAndMallCode(@Param("category") String category, @Param("mallCode") String mallCode);

	List getMerchantsByMallCode(String mallCode);

	Merchant getMerchantByMallCode(String mallCode);

	Merchant getMerchantById(String id);

	List<Merchant> findAllMerchantName(@Param("mallCode") String mallCode);

	List<Merchant> findAllmerchantNameArea(@Param("mallCode") String mallCode);

	@Select(value = "select distinct t.brand_name from t_merchant t order by convert(t.brand_name using gbk) collate gbk_chinese_ci asc")
	List<String> findNameList();

	@Select(value = "select DISTINCT t.brand_name from t_merchant t where t.brand_name is not null")
	public List<String> findAllBrandName();

	public List<Merchant> findMerchantByMallCode(@Param("mallCode") String mallCode);

	public List<String> findBrandNameByMallCode(@Param("mallCode") String mallCode);

	@Select("SELECT tm.market_name, tm.brand_name, tm.main_category_name, tm.floor_name, tm.market_address, tm.shop_name FROM t_merchant AS tm JOIN t_employee AS te ON tm.id = te.merchant_id WHERE te.id = #{employeeId}")
	Merchant findMerchantByEmployeeId(@Param("employeeId") Integer employeeId);
}
